package cn.zs.supply.common.core.aspect;

import com.netflix.servo.DefaultMonitorRegistry;
import com.netflix.servo.monitor.Counter;
import com.netflix.servo.monitor.Monitors;
import org.aspectj.lang.ProceedingJoinPoint;

public class BaseApiCounterAspect {
    static final Counter apiTotalCounter;

    static {
        apiTotalCounter = Monitors.newCounter("api.total.execute");
        DefaultMonitorRegistry.getInstance().register(apiTotalCounter);
    }


    public Object counter(ProceedingJoinPoint pjp) throws Throwable {

        try {
            return pjp.proceed();
        } finally {
            apiTotalCounter.increment();
        }
    }
}
